/**
 *  Label.java : IceBird project
 *  14:35:54 
 */
package icebird.compiler.ncomp;

/**
 * Represents dynamic(Bindable) label.
 * @author Sergey Shulepoff[Knott]
 */
public final class Label {
	
	private String name;
	
	public Label() { 
	}
	
	public Label(String str) {
		name = str;
	}
	
	/**
	 * Is this label is binded?
	 * @return boolean
	 */
	public boolean isBinded() {
		return name != null;
	}
	
	/**
	 * Bind
	 * @return void
	 */
	public void bind(String str) {
		if (isBinded()) {
			throw new RuntimeException();
		}
		
		name = str;
	}

	/* 
	 * (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	public boolean equals(Object obj) {
		if (obj == null) return false;
		
		if (obj instanceof Label) {
			Label o = (Label)obj;
			return o.name.equals(name);
		} else return false;
	}

	public String toString() {
		return name;
	}
}
